<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('businesses', function (Blueprint $table) {
            $table->id();
            $table->string('name')->default('')->comment('名称');
            $table->string('thumbnail')->default('')->comment('封面');
            $table->string('images', 2000)->default('[]')->comment('相册');
            $table->unsignedInteger('province_id')->default(0)->comment('省ID');
            $table->string('province_text', 50)->default('')->comment('省文本');
            $table->unsignedInteger('city_id')->default(0)->comment('市ID');
            $table->string('city_text', 50)->default('')->comment('市文本');
            $table->unsignedInteger('district_id')->default(0)->comment('区ID');
            $table->string('district_text', 50)->default('')->comment('区文本');
            $table->string('address')->default('')->comment('详细地址');
            $table->decimal('score', 10, 2)->default(0)->comment('评分');
            $table->decimal('lng', 20, 6)->default(0)->comment('经度');
            $table->decimal('lat', 20, 6)->default(0)->comment('维度');
            $table->string('desc')->default('')->comment('描述');
            $table->boolean('is_delete')->default(0)->comment('是否删除：1是 0否');
            $table->dateTime('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('updated_at')->default(\DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
        });
        DB::statement("ALTER TABLE `businesses` COMMENT '商业中心'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
         if (!is_production()) Schema::dropIfExists('businesses');
    }
};
